home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-03 | 5.9 KB | 314 lines | [TEXT/sLiN] |
- ! Version 3.1.0
- !
- !$ Use this script with ARA 1.0 or 2.0,
- !$ and a BBS, E-mail or other communication server software
- !
- !$ A cable for hardware handshaking is required
-
- ^2 HW handshake AT-cmd: = Text "&K3&D2"
- ^3 Normal Link AT-cmd: = Text "\N0"
- ^4 Auto-Rel Link AT-cmd: = Text "\N3"
- ^5 Link Speed AT-cmd: = Text "W1"
- ^6 Error Correction for ARA: = Bool("Enabled"="1","Disabled"="0") "0"
- ^7 Answer On: = Enum("Never"="0","1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
- ^8 Data Port Speed: = Enum("9600","19200","38400","57600") "19200"
- ! ------------------------------------------
- ! Resetting the modem:
- ! ------------------------------------------
- @Hangup
- SetTries 2
- Flush
- HsReset 0,0,0,0,0,0
- !
- ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
- ! to enter the command mode
- !
- @Label 1
- matchclr
- matchstr 1 2 "OK\r\n"
- write "ATH0V1Q0\r"
- matchread 20
- ChrDelay 1
- Write "+++"
- ChrDelay 0
- DtrClear
- SBreak
- DtrSet
- !
- DecTries
- IfTries 0 1
- !
- ! OSErr -6019 "Modem error - the modem is not responding"
- !
- exit -6019
- @Label 2
- Write "AT&F\r"
- Jsr 100
- exit 0
-
- ! ------------------------------------------
- ! Receiving incoming calls
- ! ------------------------------------------
- @ANSWER
- @Label 10
- !
- ! Set the modem preferred speed first
- SerReset Val("^8"),0,8,1
- Jsr 80
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the communication options:
- ! • Normal/AUTO Connection
- ! • HW flow control
- ! • CONNECT <DCE speed> or CARRIER/CONNECT
- !
- SetVar A "^3"
- IfStr 6 11 "0"
- SetVar A "^4"
- @Label 11
- Write "AT^2^A^5\r"
- Jsr 100
- !
- ! Get the Speaker and the Ring Num options
- GetCommand B "Data" "M"
- GetCommand C "Data" "L"
- SetVar A "S0=^7"
- !
- ! Fetch the tube after <A> rings, <B><C> - speaker options
- Write "AT^A^B^C\r"
- Jsr 100
- !
- ! Everything is ready - let's sit and wait for a call
- ! We'll wait for 2 minutes, then reinitiate the modem
- Note "Waiting for a ARA or Data call…"
- Jsr 90
- IfStr D 20 "DATA"
- Jump 10
-
- !
- ! Data connection has been established (we read "CONNECT")
- ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
- ! if it was an incoming call, put the "RING" before the "CONNECT"
- !
- @Label 20
- IfOpen "Data" 21
- Jump 30
- @Label 21
- IfOpen "ARA" 22
- Jump 35
- @Label 22
- Note "Waiting for an ARA frame"
- MatchClr
- MatchStr 1 23 "^$\r"
- MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
- MatchStr 3 29 "\01\27\02\29\01\02\01\06"
- MatchRead 40
- Jump 24
- @Label 23
- QueueInput "^$\r"
- @Label 24
- Note "Non-ARA call"
- Jump 35
-
- @Label 28
- Note "ARA 1.0 call"
- Jump 30
- @Label 29
- Note "ARA 2.0 call"
- Jump 30
-
- @Label 30
- QueueInput "\r\nCARRIER ^B\r\n"
- IfStr A 31 "NONE"
- IfStr A 31 "None"
- QueueInput "\r\nREL\r\n"
- @Label 31
- IfOriginate 32
- QueueInput "\r\nRING\r\n"
- @Label 32
- Attach "ARA" (DTR)
-
- @Label 35
- GetSReg C "DATA" 4
- QueueInput "\r^CCONNECT ^B\r^C"
- ifOriginate 36
- QueueInput "\r^CRING\r^C"
- @Label 36
- HsReset 0,1,0,0,0,1
- Attach "Data" (DTR,Escape,Break)
-
- ! ------------------------------------------
- ! Originating a call through the "ARA" subport
- ! ------------------------------------------
- @ORIGINATE "ARA"
- SerReset Val("^8"),0,8,1
- Jsr 80
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the communication options:
- ! • HW flow control
- ! • Normal Connection
- ! • CONNECT <DCE speed> or CARRIER/CONNECT
- !
- Write "AT^2^3^5\r"
- Jsr 100
- !
- ! dial the number
- Write "ATD^1\r"
- !
- ! Wait for a modem response
- Jsr 90
- IfStr D 30 "DATA"
- Write "\r"
- Exit -6019
-
- ! ------------------------------------------
- ! Originating a call through the "DATA" subport
- ! ------------------------------------------
- @ORIGINATE "Data" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
- SerReset Val("^8"),0,8,1
- Jsr 80
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the communication options:
- ! • Normal Connection
- ! • HW flow control
- ! • CONNECT <DCE speed> or CARRIER/CONNECT
- !
- Write "AT^2^4^5\r"
- Jsr 100
- !
- ! dial the number
- Write "ATD^1\r"
- HsReset *
- !
- ! Wait for a modem response
- Jsr 90
- IfStr D 35 "DATA"
- Write "\r"
- Exit -6019
-
- !
- ! This section emits all modem commands sent from the client application
- ! For each set of commands the "OK" answer is awaited
- !
- @Label 60
- EmitStart
- @Label 61
- EmitCommand 62
- Jsr 100
- Jump 61
- @Label 62
- return
- !
- ! This section initiates the modem before ANSWER and ORIGINATEs:
- ! reset on Dtr drop + DCD valid
- ! Verbal responses mode, no echo
- !
- @Label 70
- Write "AT&C1V1E0\r"
- Jsr 100
- return
-
- !
- ! This section syncronize the modem after the serial port speed switching
- !
- @Label 80
- ChrDelay 1
- Write "AT\r"
- ChrDelay 0
- Jsr 100
- return
- !
- ! Error codes
- @Label 81
- exit -6020
- @Label 82
- exit -6022
- @Label 83
- exit -6021
- @Label 84
- exit -6023
-
- !
- ! This subroutine waits for the modem response
- ! On exit, ^D contains the result code: "DATA" or "NONE"
- ! ^A contains the protocol used
- ! ^B contains the carrier speed
- ! If modem reports an error, the scripts exits with an error code
- !
- @Label 89
- Note "Ring…"
- Jump 91
-
- @Label 90
- SetVar A "NONE"
- SetVar B ""
- MatchClr
- Matchstr 1 92 "CARRIER ^$\r\n"
- Matchstr 2 93 "PROTOCOL: ^$\r\n"
-
- Matchstr 4 95 "CONNECT ^$/"
- Matchstr 5 97 "CONNECT ^$\r\n"
- Matchstr 6 89 "RING\r\n"
- Matchstr 10 82 "BUSY\r\n"
- MatchStr 11 83 "NO CARRIER\r\n"
- MatchStr 12 84 "NO ANSWER\r\n"
- MatchStr 13 81 "NO DIALTONE\r\n"
- @Label 91
- Matchread 1200
- SetVar D "NONE"
- return
-
- @Label 92
- SetVar B "^$"
- Jump 91
- @Label 93
- SetVar A "^$"
- Jump 91
-
- ! CONNECT xxxx/XXXX was detected
- @Label 95
- Jsr 98
- MatchClr
- MatchStr 1 96 "^$\r\n"
- MatchRead 10
- @Label 96
- SetVar A "^$"
- SetVar D "DATA"
- return
-
- ! CONNECT xxx was detected
- @Label 97
- Jsr 98
- SetVar D "DATA"
- return
-
- @Label 98
- ifStr B 99 ""
- return
- @Label 99
- SetVar B "^$"
- return
- !
- ! Processing the AT command:
- ! OK -> proceed
- ! ERROR or TimeOut ->exit -6019
- ! It can be called AFTER the "Write" command, since LineShare buffers input
- !
- @Label 100
- MatchClr
- MatchStr 1 102 "OK\r\n"
- MatchStr 2 101 "ERROR\r\n"
- MatchRead 20
- @Label 101
- Exit -6019
- @Label 102
- return
-